package com.group.admin.service.impl;

import com.group.admin.dao.ShopSpuDao;
import com.group.admin.entity.ShopSpuEntity;
import com.group.admin.service.ShopSpuService;
import org.springframework.stereotype.Service;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.group.common.utils.PageUtils;
import com.group.common.utils.Query;




@Service("shopSpuService")
public class ShopSpuServiceImpl extends ServiceImpl<ShopSpuDao, ShopSpuEntity> implements ShopSpuService {

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        IPage<ShopSpuEntity> page = this.page(
                new Query<ShopSpuEntity>().getPage(params),
                new QueryWrapper<ShopSpuEntity>()
        );

        return new PageUtils(page);
    }

    @Override
    public void spuadd(ShopSpuEntity shopSpuEntity) {
        //根据校验规则新增规格参数
        baseMapper.insert(shopSpuEntity);
    }

    @Override
    public void spuupdate(ShopSpuEntity shopSpuEntity) {
        //根据商品id去修改
        baseMapper.updateById(shopSpuEntity);
    }

    @Override
    public ShopSpuEntity info(Integer shopSpuId) {
        return baseMapper.selectOne(new QueryWrapper<ShopSpuEntity>().eq("shop_spu_id",shopSpuId));
    }

    @Override
    public void spudel(Integer shopSpuId) {
        //根据参数id删除
        baseMapper.deleteById(shopSpuId);
    }

}